//我收藏的职位
import React, {Component} from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';
import {enshrineStyle as styles} from '../../../../styles';//加载样式

import fmt from '../../../util/fmtDateUtil';
import sal from '../../../util/sal';
import {common_url} from "../../../util/fetch";

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class Postions extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <TouchableOpacity
                activeOpacity={0.5}//透明度
                onPress={() => {
                    this.goGet('Postionin', this.props.postion.postionId);
                }}
                style={styles.meoneallin}>

                <Image source={
                    this.props.postion.company.companyPicture ?
                    {uri: common_url + "uploadImg/" + this.props.postion.company.companyPicture}
                    : require('../../../img/app/company.png')} style={styles.head}/>
                <View style={[styles.meoneline, {width: width * 0.78}]}>

                    <View style={styles.meone1}>
                        <Text style={styles.meonepoz}>{this.props.postion.postionName}</Text>
                        <Text
                            style={styles.meonemoney}>{sal(this.props.postion.postionMm, this.props.postion.postionYm)}</Text>
                    </View>
                    <View style={styles.meone2}>
                        <Text style={styles.meonename}>{this.props.company.companyName}</Text>
                    </View>
                    <View style={styles.meone3}>
                        <Text style={styles.meonenon}>{this.props.postion.postionSpace}</Text>
                        <Text style={styles.meonenon}>{this.props.postion.postionExp}年经验</Text>
                        <Text style={styles.meonenon2}>{this.props.postion.postionEducation}</Text>
                    </View>
                    <View style={styles.meone4}>
                   
                        {this.fieldName(this.props.domains, 3)}
                        <Text style={styles.meonetime}>{fmt(this.props.postions.collectTime, "yyyy-MM-dd")}</Text>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }

    //经营领域
    fieldName(List, sl) {
        var data = {
            cont: List
        }
        var arr = [];                            //用来装公司类型
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.meonesmall}>{data.cont[i].field.fieldName}</Text>
            )
        }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, {useId: id});
    }
}